﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="UC_KhachHang_List.ascx.cs" Inherits="QuanLyKhachSan.UC_KhachHang_List" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<style type="text/css">
	.ui-dialog { font-size: 11px; }
	body {
		font-family: Tahoma;
		font-size: 12px;
	}
	#question {
		width: 450px!important;
		height: 60px!important;
		padding: 10px 0 0 10px;
	}
	#question img {
		float: left;
	}
	#question span {
		float: left;
		margin: 20px 0 0 10px;
	}
</style>
<script type="text/javascript" language="javascript">
    function frmThemKhachHang_Add() {
        try {
            var URL = '<%=ResolveUrl("~/Pages/PopUp.aspx")%>';
            URL += "?UCName=UC_KhachHang_Edit&UCPath=QuanLyKhachHang"
            var oRadWindowManager = $find("<%= RadWindowManager1.ClientID %>");
            var frmThemKhachHang = oRadWindowManager.open(URL, "frmThemKhachHang");
            frmThemKhachHang.SetSize(460, 480);
        } catch (e) {
            alert(e);
        }
    }
    function frmThemKhachHang_Edit(KhachHangID) {
        try {
            var URL = '<%=ResolveUrl("~/Pages/PopUp.aspx")%>';
            URL = URL + "?UCName=UC_KhachHang_Edit&UCPath=QuanLyKhachHang&KhachHangID=" + KhachHangID;
            var oRadWindowManager = $find("<%= RadWindowManager1.ClientID %>");
            var frmThemKhachHang = oRadWindowManager.open(URL, "frmThemKhachHang");
            frmThemKhachHang.SetSize(460, 480);
        } catch (e) {
            alert(e);
        }
    }
    function KhachHang_Delete(KhachHangID,HoTen) {
        try {
            var retOK = confirm("Bạn muốn xóa thông tin khách hàng: " + HoTen);
            if (retOK) {
                var URLService = '<%=ResolveUrl("~/Service/QuanLyKhachHang/KhachHang.asmx")%>';
                var Method = "KhachHang_Delete";
                $.ajax({
                    type: "POST",
                    url: URLService + "/" + Method,
                    data: "{KhachHangID:" + '"' + KhachHangID + '"}',
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: OnSuccess,
                    error: OnError
                });
            }            
        } catch (e) {
            alert(e);
        }
    }
    function OnSuccess(data, status) {
        __doPostBack('<%=pnlKhachHang.ClientID%>', '');
    }

    function OnError(request, status, error) {
        alert("Có sự cố trong quá trình xử lý.Vui lòng kiểm tra lại!");
    }
    function cmdThemKhachHang_OnClientClicking(sender, args) {
        try {
            args.set_cancel(true);
            frmThemKhachHang_Add();
        } catch (e) {

        }
    }
    
    function OnClientClose(sender, eventArgs) {
        try {
            __doPostBack('<%=pnlKhachHang.ClientID%>', '');
        } catch (e) {

        }
    }
    function OnClientSelectedIndexChanging_Handler(sender, eventArgs) {
        try {
            frmDatPhong_Add();
        } catch (e) {

        }
    }
    function frmDatPhong_Add() {
        try {
            var URL = '<%=ResolveUrl("~/Pages/PopUp.aspx")%>';
            URL += "?UCName=UC_DatPhong&UCPath=QuanLyDatPhong"
            var oRadWindowManager = $find("<%= RadWindowManager1.ClientID %>");
            var frmDatPhong = oRadWindowManager.open(URL, "frmDatPhong");
            frmDatPhong.SetSize(460, 480);
        } catch (e) {
            alert(e);
        }
    }
</script>
  <telerik:RadWindowManager ID="RadWindowManager1" runat="server" 
            EnableShadow="true" Skin="Windows7" Modal="true" VisibleStatusbar="false" >
            <Windows>
                 <telerik:RadWindow  
                    id="frmThemKhachHang" 
                    runat="server"
                    showcontentduringload="false"
                    width="530px"
                    height="400px"
                    title="Cập nhật khách hàng"
                    behaviors="Close,Move,Resize,Maximize"  Animation="Resize" ReloadOnShow="true" OnClientClose="OnClientClose"  >
                </telerik:RadWindow>
                <telerik:RadWindow  
                    id="frmDatPhong" 
                    runat="server"
                    showcontentduringload="false"
                    width="620px"
                    height="400px"
                    title="Đặt phòng"
                    behaviors="Close,Move,Resize,Maximize"  Animation="Resize" ReloadOnShow="true" OnClientClose="OnClientClose"  >
                </telerik:RadWindow>
            </Windows>
        </telerik:RadWindowManager>
<!-- List -->
<table width="100%">
    <tr>
        <td>
            <telerik:RadComboBox ID="cbxChonThaoTac" runat="server" EmptyMessage="Chọn thao tác" Width="120px" OnClientSelectedIndexChanging="OnClientSelectedIndexChanging_Handler">
                <Items>
                    <telerik:RadComboBoxItem Text="Đặt phòng" />
                    <telerik:RadComboBoxItem Text="Nhận phòng" />
                    <telerik:RadComboBoxItem Text="Thêm vào phòng" />
                </Items>
            </telerik:RadComboBox>
        </td>
    </tr>
    <tr>
        <td>
            <asp:UpdatePanel ID="pnlKhachHang" runat="server">                
                <ContentTemplate>
                    <telerik:RadGrid ID="lstKhachHang" runat="server" Skin="Windows7">
                        <MasterTableView DataKeyNames="KhachHangID" AutoGenerateColumns="false" GridLines="None">
                            <CommandItemSettings ExportToPdfText="Export to Pdf" />   
                            <Columns>              
                                <telerik:GridTemplateColumn HeaderText="Họ tên">
                                    <ItemTemplate>
                                        <asp:CheckBox ID="cbx" runat="server" /> <%#Eval("HoTen")%>
                                    </ItemTemplate>
                                    <HeaderStyle HorizontalAlign="Left" Width="200" />
                                    <ItemStyle HorizontalAlign="Left"/>
                                </telerik:GridTemplateColumn>
                                <telerik:GridTemplateColumn HeaderText="Giới tính">
                                    <ItemTemplate>
                                        <%# (int)Eval("GioiTinh") == -1 ? "---" : ((int)Eval("GioiTinh") == 1 ? "Nữ" : "Nam") %>
                                    </ItemTemplate>
                                    <HeaderStyle HorizontalAlign="Left" Width="70" />
                                    <ItemStyle HorizontalAlign="Left"/>
                                </telerik:GridTemplateColumn>
                                <telerik:GridTemplateColumn HeaderText="Địa chỉ">
                                    <ItemTemplate>
                                        <%#Eval("DiaChi")%>
                                    </ItemTemplate>
                                    <HeaderStyle HorizontalAlign="Left" Width="200" />
                                    <ItemStyle HorizontalAlign="Left"/>
                                </telerik:GridTemplateColumn>
                                <telerik:GridTemplateColumn HeaderText="CMND/Passport">
                                    <ItemTemplate>
                                        <%#Eval("CMND")%>
                                    </ItemTemplate>
                                    <HeaderStyle HorizontalAlign="Left" Width="80" />
                                    <ItemStyle HorizontalAlign="Left"/>
                                </telerik:GridTemplateColumn>
                                <telerik:GridTemplateColumn HeaderText="Điện thoại">
                                    <ItemTemplate>
                                        <%#Eval("DienThoai")%>
                                    </ItemTemplate>
                                    <HeaderStyle HorizontalAlign="Left" Width="100" />
                                    <ItemStyle HorizontalAlign="Left"/>
                                </telerik:GridTemplateColumn>
                                <telerik:GridTemplateColumn HeaderText="Chỉnh sửa">
                                    <ItemTemplate>
                                        <span onclick="frmThemKhachHang_Edit(this.title)" title='<%#Eval("KhachHangID") %>' style=" cursor:pointer">Sửa </span>|<span onclick="KhachHang_Delete(this.id,this.title)" title='<%#Eval("HoTen") %>' id='<%#Eval("KhachHangID") %>' style=" cursor:pointer"> Xóa</span>                                                                                
                                    </ItemTemplate>
                                    <HeaderStyle HorizontalAlign="Left" Width="70" />
                                    <ItemStyle HorizontalAlign="Left"/>
                                </telerik:GridTemplateColumn>
                            </Columns>                    
                        </MasterTableView>          
                    </telerik:RadGrid>              
                </ContentTemplate>
            </asp:UpdatePanel>        
        </td>
    </tr>
    <tr>
        <td>            
            <telerik:RadButton ID="cmdThemKhachHang" runat="server" Text="Thêm khách hàng" OnClientClicking="cmdThemKhachHang_OnClientClicking">
            </telerik:RadButton>
        </td>
    </tr>
</table>


